package org.wu.framework.web.spring.ui;

import org.springframework.web.servlet.resource.VersionResourceResolver;
import org.wu.framework.web.ui.LazyUI;
import org.springframework.web.servlet.config.annotation.ResourceHandlerRegistry;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;

import java.util.List;

public class LazyUIWebMvcConfigurerRegister implements WebMvcConfigurer {
    private final List<LazyUI> lazyUIList;

    public LazyUIWebMvcConfigurerRegister(List<LazyUI> lazyUIList) {
        this.lazyUIList = lazyUIList;
    }

    /**
     * 设置静态资源映射
     *
     * @param registry 资源注册器
     */
    @Override
    public void addResourceHandlers(ResourceHandlerRegistry registry) {
        for (LazyUI lazyUI : lazyUIList) {

            if (lazyUI.support()) {
                //            registry.addResourceHandler("/acw-client-ui/**").addResourceLocations("classpath:/acw-local-client/v1/");
                registry.addResourceHandler(lazyUI.pathPatterns())
                        .addResourceLocations(lazyUI.locations())
                        ;
            }

        }

    }
}
